home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 1.iso / games / pundit.zip / PUNDIT.TXT < prev   
Text File  |  1990-11-29  |  15KB  |  397 lines

  1.  
  2. ----------
  3. Pundit
  4. ----------
  5.  
  6.  
  7.                      -- INTRODUCTION --
  8.  
  9. Pundit is a Microsoft Windows 3.0 program that pops up a
  10. Window to display a quotation, fortune, or other basically
  11. useless (but hopefully entertaining) saying.  The Window
  12. remains on the screen for a given amount of time then
  13. disappears, to return with a new quote later.
  14.  
  15. The amount of time that the Window remains on the screen
  16. and the amount of time that it stays hidden may both be set
  17. by the user.
  18.  
  19. This program has two purposes:
  20.  
  21.     1) to be a (mildly) amusing diversion and excuse for
  22.        why you couldn't get that Excel spreadsheet done
  23.        on time
  24.  
  25.     2) to provide budding Windows programmers with an
  26.        example of some of the things that can be done
  27.        with Windows 3.0
  28.  
  29. This program is "shareware"; it is copyrighted, but is
  30. being made available to the outside world by the author.
  31. Feel free to distribute this program to your friends, but
  32. please stay within the following restrictions:
  33.  
  34.     1) No charge may be made for distribution of this
  35.        program beyond the nominal fees charged by
  36.        organizations that are in the "business" of
  37.        distributing "shareware".
  38.  
  39.     2) The entire package (executable, source, icon,
  40.        documentation, etc.) MUST be distributed together.
  41.        It is not fair for you to benefit from having the
  42.        source code if you won't share it.
  43.  
  44.     3) No modifications may be made to the distributed
  45.        program (especially the copyright notice).  You may
  46.        make changes in your own copy (such as changing the
  47.        quotations) so long as you DO NOT change the
  48.        copyright notice and you distribute the original in
  49.        exactly the same condition in which you received it.
  50.  
  51.  
  52. If you like this program, a donation of $5 (five dollars)
  53. would be appreciated --- this will not make me rich, but it
  54. will encourage me to release more programs (with source).
  55. Send any donations to:
  56.  
  57.                        Jeff Bienstadt
  58.                    18092 Muirwoods Court
  59.                  Fountain Valley, CA  92708
  60.  
  61. If you have any questions or comments about this program, I
  62. would love to hear from you (this includes Windows Wizards
  63. with comments about how to improve it).  I can be reached
  64. at the above address or on CompuServe at 72200,3477.
  65.  
  66.  
  67.  -- Files in the Distribution --
  68.  
  69. The distribution contains the following files:
  70.  
  71.     PUNDIT.EXE    The executable program
  72.     PUNDIT.TXT    This file
  73.     PUNDIT.H      Header file containing important constants
  74.     PUNDIT.C      The C source code
  75.     PUNDIT.RC     The resource file (the quotations are here)
  76.     PUNDIT.ICO    The Icon
  77.     PUNDIT.MAK    The make file (for NMAKE)
  78.     PUNDIT.DEF    The Linker Definition File
  79.  
  80. Please be sure that you have all of these files in your distribution
  81.  
  82.     
  83.  
  84.                      -- USER'S GUIDE --
  85.  
  86. Pundit is very easy to use.  Run it by any of the
  87. "normal" Windows methods of launching a program.
  88.  
  89. When Pundit starts up, it will place a Window near the
  90. upper-left corner of your screen, and display a quotation
  91. in the Window.  After about 5 seconds, the Window will
  92. vanish.  About 20 seconds later, the Window will reappear,
  93. displaying a new quotation, and the cycle will start over
  94. again.
  95.  
  96. Pundit may not be minimized or maximized; you may move
  97. the Window around the screen, and you may resize it, but
  98. you cannot make an icon of it.
  99.  
  100. While the Window is displayed it may be resized and/or
  101. moved, and the Menu is available.
  102.  
  103.  
  104.  -- The Menu --
  105.  
  106. Besides the "system" menu (for sizing, etc.) Pundit
  107. contains one menu.  From this menu you may change the
  108. settings that Pundit uses, see an "About" box, or exit
  109. Pundit.
  110.  
  111. Once the menu is activated, Pundit will suspend counting
  112. seconds, and will stay active while you work. (It would be
  113. somewhat disconcerting to have the Window disappear while
  114. you are deciding what to do.)
  115.  
  116.  
  117.  - Settings... -
  118.  
  119. Choosing the "Settings..." memu item brings up a dialog box
  120. which will allow you to change the amount of time that the
  121. Window is displayed and hidden.
  122.  
  123. There are two horizontal scroll bars -- one for each of the
  124. two time settings -- and the current time setting for each
  125. is displayed in a box to the right of the scroll bar.
  126. Moving the scroll bar to the right will increase the amount
  127. of time, moving it to the left will decrease the amount of
  128. time.
  129.  
  130. The amount of time that the Window is visible ranges from
  131. 1 second to 60 seconds (1 minute).  The amount of time that
  132. the Window is hidden ranges from 1 second to 3600 seconds
  133. (1 hour).
  134.  
  135.  
  136. There are also three buttons -- "OK", "CANCEL", and
  137. "Save Settings" -- that determine what happens to the
  138. settings you change.
  139.  
  140. Pressing the "OK" button will make Pundit act on your
  141. changes for now, but will NOT save them; the next time you
  142. run Pundit the settings will revert to what they were
  143. before you changed the settings.
  144.  
  145. Pressing the "CANCEL" button will ignore the changes you
  146. make and Pundit will continue on as before.
  147.  
  148. Pressing the "Save Settings" button will save your settings
  149. choices in the WIN.INI file.  You will also be asked if you
  150. want to save the current position and size of the Window
  151. (in case you moved or resized it).  Pressing the "Yes"
  152. button will save the current size/position as well as the
  153. new timer values.  Pressing the "No" button will save the
  154. new timer values, but not the size/position.
  155.  
  156. Pressing the "Save Settings" button will NOT exit the
  157. dialog box; you will need to press the "OK" or "CANCEL"
  158. buttons to return Pundit to its normal operation.
  159.  
  160.  
  161.  - About Pundit... -
  162.  
  163. Choosing the "About Pundit..." menu item will bring up a
  164. basic "About" dialog box which just tells you what program
  165. it is and contains my copyright notice.
  166.  
  167.  
  168.  - Exit -
  169.  
  170. Choosing the "Exit" menu item will terminate Pundit.
  171.  
  172.  
  173.  
  174.  -- The WIN.INI Entry --
  175.  
  176. When you change settings and save them (from the
  177. "Save Settings" dialog box), Pundit creates (or modifies)
  178. an entry in your WIN.INI file.  The heading for this
  179. section is [jkbPundit] (it seemed like a reasonably unique
  180. name).  There are six entries under this section:
  181.  
  182.     InSecs=n    number of seconds the Window is shown
  183.     OutSecs=n   number of seconds the Window is hidden
  184.     X=n         the X position (column) of the Window
  185.     Y=n         the Y position (row) of the Window
  186.     Width=n     the width of the Window
  187.     Height=n    the height of the Window
  188.  
  189.     (in the above, n represents a number)
  190.  
  191. Deleting any of these item will cause Pundit to revert
  192. to its "default" behavior for that item.
  193.  
  194.  
  195.  -- Caveats --
  196.  
  197.     1)  Pundit does NOT know what is happening with any
  198.         other Window, so when Pundit pops up it may
  199.         disrupt what you are doing. This includes making
  200.         the menus on other Windows go away, and canceling
  201.         the "Switch to..." dialog box.
  202.         Also, any keyboard operations you may be performing
  203.         will suddenly stop when Pundit pops up, unless you
  204.         re-activate the Window you were working in.  Control
  205.         of the window you were working in will be restored
  206.         when Pundit hides its Window.
  207.  
  208.     2)  If you are blazing fast and furious with the mouse
  209.         in some Windows application (such as Solitiare),
  210.         you may notice that your application froze for a
  211.         moment and is suddenly being repainted.  Don't
  212.         panic!  All that happened is that Pundit popped up
  213.         on top of that application (temporarily de-activating
  214.         that application's Window) and you clicked the
  215.         mouse somewhere within the application Windows'
  216.         client area that was not covered by Pundit, and
  217.         your original application was brought back up to
  218.         the fore and the client are was repainted.
  219.         This is sometimes annoying, but not fatal.
  220.  
  221.     3)  A few of the quotations in Pundit were formatted
  222.         to use multiple lines (such as a poem or cheer). 
  223.         The default size of the Window is really not big
  224.         enough to display these quotations correctly, so
  225.         they may wrap strangely at the right edge of the
  226.         Window or may be clipped at the bottom edge.  When
  227.         these quotations are displayed, you have two
  228.         choices:
  229.  
  230.             a)  Resize the window to give more room for the
  231.                 quotation, or
  232.  
  233.             b)  Ignore the quotation altogether
  234.  
  235.  
  236.     4)  Pundit uses the rand() function in the Microsoft
  237.         C 6.0 library.  This is a fairly good random-number
  238.         system, but it is NOT perfect, so it is possible
  239.         that some quotations may repeat themselves while
  240.         others may not show up at all.  To be fair, when
  241.         Pundit starts up,  I call the srand() function,
  242.         passing it part of the current system time. This is
  243.         probably NOT the best way to seed the random-number
  244.         generator, but it is one of the most convenient, so
  245.         I will accept part of the blame for repeated text.
  246.  
  247.  
  248.  
  249.                -- PROGRAMMER'S INFORMATION --
  250.  
  251. Pundit is distributed with the complete source code,
  252. heavily commented.  In some places the comments tend to
  253. severely clutter up the listing, so if you want to remove
  254. some of the comments to improve readability, please do so
  255. (remembering that you may not distribute it that way).
  256.  
  257. It is not my intention to fully explain how each aspect of
  258. the code works -- you can look up most of it in the Windows
  259. SDK documentation -- but I do want to make a few points
  260. about some of the interesting(?) things this program makes
  261. use of.  Among these are the use of the STRINGTABLE
  262. resource, private messages, and an error in the Windows SDK
  263. documentation.
  264.  
  265. When reading the source code, beware of where the commas
  266. are.  For some of the internal strings, I have used the C
  267. language's string constant concatenation feature to
  268. "improve" readability of the string constants.
  269.  
  270.  
  271.  -- The STRINGTABLE --
  272.  
  273. All of the quotations used by this program are contained
  274. within a STRINGTABLE resource in Pundit.rc.  Some of
  275. these strings are made up of more than one line.  If you
  276. look at the quotes in Pundit.rc, you will see that some
  277. of them contain the substring \012.  This is an octal
  278. (base 8) contant that represents a LineFeed, and tells
  279. Windows to break the line at that point.  I have indented
  280. each new line by two spaces in order to help visually
  281. separate "real" line breaks from line breaks that Windows
  282. has produced.
  283.  
  284. You may also notice an occasional substring of \042. This
  285. allows the use of the double-quote character (") within a
  286. string.
  287.  
  288. The primary advantage to the STRINGTABLE resource is that
  289. Windows loads the strings into memory ONLY WHEN IT NEEDS
  290. TO, rather than having them taking up precious memory for
  291. the entire time Pundit is running.  Also, it makes it
  292. easier to modify (or add or delete) quotations -- only the
  293. resource needs to be recompiled and linked rather than the
  294. C source file.
  295.  
  296. NOTE:
  297.     In the Pundit.h file, there is a #define'd constant
  298.     MAX_STRING.  This should be set to the ID value of the
  299.     last quotation in the STRINGTABLE.  If you add or
  300.     delete quotation from the STRINGTABLE, you MUST change
  301.     the value of this constant or Pundit will behave
  302.     badly.
  303.  
  304. NOTE:
  305.     Some of the entries in the STRINGTABLE are lines that
  306.     exceed 200 characters.  If your editor imposes a maximum
  307.     line length (such as Brief) you may need to either use
  308.     a different editor (The Norton Editor will handle very
  309.     long lines), or reconfigure your editor to accept a
  310.     longer line (you can do this for Brief in the "setup"
  311.     program).
  312.  
  313.  
  314.  
  315.  -- Private Messages --
  316.  
  317. Windows Programs are not limited to the Messages described
  318. in Windows.h -- you may Send, Post, and process your own
  319. messages if you wish.  Pundit uses two private messages,
  320. WM_jkb_START and WM_jkb_PAUSE (which are used to inform
  321. Pundit to start and suspend the timer).  These private
  322. messages are given values higher than that of WM_USER in
  323. order to ensure that they do not conflict with the standard
  324. Windows Messages.
  325.  
  326.  
  327.  -- Knowing About the Menu --
  328.  
  329. One important consideration when designing a program like
  330. this is that you do not want the Window to vanish when a
  331. menu is up and the user is deciding what he/she wants to
  332. do.  Also, if the user decides to cancel the menu (with the
  333. ESC key or clicking outside the menu area), the program
  334. needs to return to normal operation.
  335.  
  336. Fortunately, Windows provides a couple of Messages to help
  337. in this situation, namely WM_INITMENU and WM_MENUSELECT.
  338. Unfortunately, the documentation for WM_MENUSELECT is
  339. incomplete and slightly incorrect (at least in my copy of
  340. the SDK).
  341.  
  342. When the user activates a menu, Windows sends a WM_INITMENU
  343. Message to the application.  This is great, since it allows
  344. us to know that a menu was activated and gives us the
  345. opportunity to shut down the timer while the menu is up,
  346. thus preventing our Window from vanishing for a while.
  347.  
  348. Windows also sends a WM_MENUSELECT message each an item is
  349. selected (highlighted) on that menu, and the wParam and
  350. lParam values contain information about what was selected.
  351. But here's where the problems come in: the documentation
  352. for the WM_MENUSELECT message says:
  353.  
  354.     If the low-order word of the lParam parameter contains
  355.     -1 and the high-order word of the wParam parameter
  356.     contains 0, Windows has closed the menu because the user
  357.     pressed ESC or clicked outside the menu.
  358.  
  359. First of all, there is what appears to be a typographical
  360. error in this description: what need to be checked for 0 is
  361. the high-order word of lParam, not wParam (wParam does not
  362. have a high-order and low-order word -- it is just one
  363. word).
  364.  
  365. That's the slightly incorrect part; the incomplete part is
  366. that what they don't tell you is that the conditions of
  367. wParam and lParam apply whenever Windows closes the menu
  368. EVEN IF THE USER CHOSE A MENU ITEM!  (Run the Windows SDK
  369. "Spy" utility on an application and choose a menu item --
  370. you'll see the Message).
  371.  
  372. Because of this situation, we have to shut down the timer
  373. for Pundit when we enter a dialog box (unless we want the
  374. main Window to vanish while a dialog box is active).  This
  375. is done by processing the WM_INITDIALOG Message and shutting
  376. down the timer in each of the two dialog boxes in Pundit.
  377.  
  378. This is by no means as bad a situation as it sound here. 
  379. It was just a little annoying, since it was not documented
  380. correctly, and it took a little time to track down (thank
  381. Microsoft for "Spy"!)
  382.  
  383.  
  384.  
  385.  
  386.  
  387. I hope that those of you who are newer to programming for
  388. Windows than I am will benefit from all this, and that
  389. those of you who are more experienced will point out any
  390. errors or improvements.
  391.  
  392.  
  393.  
  394.                 Jeff Bienstadt
  395.  
  396.  
  397.